package com.newbingo.dto;

import java.io.Serializable;
import java.util.List;

import com.newbingo.dao.imple.ITradeRecordDao;
import com.newbingo.dto.imple.ITradeRecordDto;
import com.newbingo.entity.TradeRecord;
import com.newbingo.util.Pager;

/**
 * 交易记录DTO对象
 * @author ChansonYan
 *
 */
public class TradeRecordDto implements ITradeRecordDto,Serializable {
	private ITradeRecordDao tradeRecordDao=null;
	private String tradeTime;
	private Integer score;
	private String tradeType;
	private Integer amount;
	private String handler;
	
	/*
	 * 根据查询出的交易记录实体对象转换为DTO集合的Pager对象
	 */
	/* (non-Javadoc)
	 * @see com.newbingo.dto.ITradeRecordDto#findByPage(int, int, java.lang.String)
	 */
	public Pager findByPage(int start,int limit,Integer uno){
		Pager page_dto=new Pager();
		Pager page=tradeRecordDao.findByPage(start, limit, uno);
		page_dto.setTotalSize(page.getTotalSize());
		List<TradeRecord> records=page.getData();
		if(records!=null && records.size()>0){
			for(TradeRecord record : records){
				TradeRecordDto recordDto=new TradeRecordDto();
				recordDto.setAmount(record.getAmount());
				if(record.getAgent()!=null)
					recordDto.setHandler(record.getAgent().getUname());
				recordDto.setScore(record.getScore());
				if(record.getTradeTime()!=null)
					recordDto.setTradeTime(record.getTradeTime().toString());
				recordDto.setTradeType(record.getType());
				page_dto.getData().add(recordDto);
			}
		}
		return page_dto;
	}
	
	
	public String getTradeTime() {
		return tradeTime;
	}
	public void setTradeTime(String tradeTime) {
		this.tradeTime = tradeTime;
	}
	public Integer getScore() {
		return score;
	}
	public void setScore(Integer score) {
		this.score = score;
	}
	public String getTradeType() {
		return tradeType;
	}
	public void setTradeType(String tradeType) {
		this.tradeType = tradeType;
	}
	public Integer getAmount() {
		return amount;
	}
	public void setAmount(Integer amount) {
		this.amount = amount;
	}
	public String getHandler() {
		return handler;
	}
	public void setHandler(String handler) {
		this.handler = handler;
	}
	public ITradeRecordDao getTradeRecordDao() {
		return tradeRecordDao;
	}
	public void setTradeRecordDao(ITradeRecordDao tradeRecordDao) {
		this.tradeRecordDao = tradeRecordDao;
	}

}
